#!/bin/make
#

#
# commands
#

RM = del /F /Q
AS = ca65
LD = ld65

#
# Flags
#

ASFLAGS = -t vic20 -g  -I . -I ..\..\prototype
LDFLAGS =  

#
# Sources
#

FIRE_SOURCES = \
	fire20.asm
FIRE_OBJECTS = $(patsubst %.asm,%.o,$(FIRE_SOURCES))

FIREPAL_SOURCES = \
	fire20_unexp.asm
FIREPAL_OBJECTS = $(patsubst %.asm,%.o,$(FIREPAL_SOURCES))

LOADER_SOURCES = \
	loader.asm
LOADER_OBJECTS = $(patsubst %.asm,%.o,$(LOADER_SOURCES))

TARGETS = fire20.bin loader.prg fire_pal.prg

#
# targets
#

.PHONY : all clean install

all:	$(TARGETS)

install:

clean:
	$(RM) $(FIRE_OBJECTS) $(LOADER_OBJECTS) $(SID_OBJECTS) $(TARGETS) $(patsubst %.bin,%.map,$(TARGETS)) $(patsubst %.bin,%.lbl,$(TARGETS))

fire20.bin:		$(FIRE_OBJECTS) 
	$(LD) $(LDFLAGS) -C vic20-fire.cfg -m $(patsubst %.bin,%.map,$@) -Ln $(patsubst %.bin,%.lbl,$@) -o $@ $^

fire_pal.prg:	$(FIREPAL_OBJECTS) 
	$(LD) $(LDFLAGS) -C vic20-fire_unexp.cfg -m $(patsubst %.prg,%.map,$@) -Ln $(patsubst %.prg,%.lbl,$@) -o $@ $^

loader.prg:		$(LOADER_OBJECTS) 
	$(LD) $(LDFLAGS) -C vic20-load.cfg -m $(patsubst %.prg,%.map,$@) -Ln $(patsubst %.prg,%.lbl,$@) -o $@ $^

#
# Pattern rules
#

.SUFFIXES:
.SUFFIXES: .asm .o

%.o : %.asm
	$(AS) $(ASFLAGS) -o $@ $<
